Vue.component("myheader",{
    //el : "#app",
    template : `
    \t<div id="header" class="wrap">
    \t\t<div id="logo">
    \t\t\t<img src="images/logo.gif" />
    \t\t</div>
    \t\t<div class="search">
    \t\t\t<a v-if="!logindedUser" href="login.html">登录</a>
    \t\t\t<a v-if="!logindedUser" href="register.html">注册</a>
            <span v-if="logindedUser">欢迎：{{logindedUser.name}}</span>
    \t\t\t<label v-if="logindedUser" class="ui-green"><input @click="add()" type="button" name="search" value="发布房屋信息" /></label>
    \t\t\t<label v-if="logindedUser" class="ui-green">
    <input type="button" name="search" value="退       出" @click="logout()" /></label>
    \t\t</div>
    \t</div>
    `,
    data(){
        return {
            logindedUser : null
        };
    },
    created(){
        this.refreshLoginedUser();
    },
    methods : {
        logout(){
            axios.get("/c118s3plyqnzf/users/logout").then(res=>{
                this.logindedUser = null;
                alert(res.data.msg);
            })
        },
        refreshLoginedUser(){
            axios.get("/c118s3plyqnzf/users/getLoginedUser").then(res=>{
                if (res.data.code){
                    this.logindedUser = res.data.data;
                }
            })
        },
        add(){
            location.href="add.html"
        }
    }

})

Vue.component("myfooter", {
    template : `
    \t<div id="footer" class="wrap">
    \t\t<dl>
    \t\t\t<dt>青鸟租房 &copy; 2015 源辰信息科技有限公司 湘ICP证1000001号</dt>
    \t\t\t<dd>关于我们 · 联系方式 · 意见反馈 · 帮助中心</dd>
    \t\t</dl>
    \t</div>
`
})